<!--suppress ALL -->
<template>
<div class="page fireHazardHistoryList-page"
	data-page="fireHazardHistoryList" style="z-index: 2;">
	<div class="link-page-nav">
		<a href="#" class="link" @click="$root.backToTab()"> 
      <i class="iconfont icon-zuo"></i>
		</a>
	</div>
	<div class="link-page-top" style="padding-bottom: 17px;">
		<div class="link-page-title">历史记录</div>
	</div>
	<div class="history-list-select">
		<a class="link popover-open" id="active_{{getNewId}}" style="color: #000000;"
			data-popover="#fireHazardHistoryList_menu"> <i
			class="iconfont icon-APPicon_shaixuan1
" style="font-size: 24px;"></i>
		</a>
	</div>
	<div class="page-content infinite-scroll-content"
		data-infinite-distance="55" @infinite="loadMore" style="padding-bottom: 120px;">
		<ul class="fireHazardList-list-item fireHazardHistoryList_list"
			id="fireHazardHistoryList_list_{{getNewId}}">

		</ul>
		<div id="fireHazardHistoryList_preloader_{{getNewId}}"
			class="preloader infinite-scroll-preloader"></div>
	</div>
	<div class="popover select-option-con" id="fireHazardHistoryList_menu">
		<div class="popover-angle"></div>
		<div class="popover-inner">
			<div class="list">
				<ul>
					<li><a href="" class="list-button item-link popover-close"
						id="fireHazardHistoryList_org_{{getNewId}}">选择单位</a></li>
					<li><a href="" class="list-button item-link popover-close"
						@click="getTbTime" id="fireHazardHistoryList_date_{{getNewId}}">选择日期</a></li>
					<li><a href=""
						class="list-button item-link popover-close removeScreen select-active"
						@click="removeScreen">清&nbsp&nbsp&nbsp&nbsp&nbsp空</a></li>
				</ul>
			</div>
		</div>
	</div>
</div>

</template>
<script>
    return {
        mounted() {
            var self = this;
            if (single_Orgid == "") {
              self.organizationIds=userInfor.organizationIds;
            } else {
              self.organizationIds=single_Orgid;
            }
        },
        data: function () {
            return {
              pageIndex:0,
              pageSize:8,
              isInfinite:true,
              organizationIds:"",
              startTimeStr:"",
              endTimeStr:"",
              selectOptionIndex:'',
              selectOptionOrg : "",
              getNewId: (new Date()).getTime()
            }
        },
        methods: {
            removeScreen:function(){
                var self = this;
                if (userInfor.isMuilUnitUser == 1){//多
                    self.selectOptionOrg = "";
                    if (single_Orgid == "") {
                      self.organizationIds=userInfor.organizationIds;
                    } else {
                      self.organizationIds=single_Orgid;
                    }
                    jQuery("#fireHazardHistoryList_org_"+self.getNewId).html("选择单位");
                    jQuery("#fireHazardHistoryList_org_"+self.getNewId).removeClass('select-active');
                }
                self.selectOptionIndex = "";
                self.startTimeStr = "";
                self.endTimeStr = "";
                jQuery("#fireHazardHistoryList_date_"+self.getNewId).html("选择日期");
                jQuery("#fireHazardHistoryList_date_"+self.getNewId).removeClass('select-active');

                jQuery("#fireHazardHistoryList_list_"+self.getNewId).empty();
                self.clearContent();
                self.showfireHazardHistoryList();
            },
            showfireHazardHistoryList:function(){
                var self = this;
                var $ = self.$$;
                //筛选按钮有值变色
                if(jQuery("#fireHazardHistoryList_date_"+self.getNewId)[0].innerText != "选择日期" || jQuery("#fireHazardHistoryList_org_"+self.getNewId)[0].innerText != "选择单位"){
                   jQuery("#active_" + self.getNewId).addClass("select-active");
                }else{
                    jQuery("#active_" + self.getNewId).removeClass("select-active");
                }
                Dao.getHighRiskList({
                  userName: userInfor.accountName,
                  organizationIds:self.organizationIds,
                  isReset:1,
                  handlerStatus:"",
                  startTimeStr:self.startTimeStr,
                  endTimeStr:self.endTimeStr,
                  queryType:1,
                  timeType:13,
                  pageIndex:self.pageIndex,
                  pageSize:self.pageSize
                },function(data){
                  if(data && data.length>0){
                    //没分页
                    if(data.length<self.pageSize){
                      $("#fireHazardHistoryList_preloader_"+self.getNewId).hide();
                      self.isInfinite = false;
                    }else {
                      $("#fireHazardHistoryList_preloader_"+self.getNewId).show();
                      self.isInfinite = true;
                    }
                    for(var i=0;i<data.length;i++){
                      //表示未处理
                      if( data[i].handlerStatus==0){
                        $("#fireHazardHistoryList_list_"+self.getNewId).append(`
                        <li class="highDager_detail" data-id="`+data[i].id+`">
                          <div class="highDanger-item-border">
                            <div class="highDanger-item-num">`+data[i].alertNum+`</div>
                            <div class="highDanger-item-name">火情数量</div>
                          </div>
                          <div class="highDanger-item-desc">`+data[i].selfDesc+`</div>
                          <div class="highDanger-item-unit-desc"><i class="iconfont icon-APPicon_dingwei" style="color:#2471CA;margin-left:-3px;"></i><span class="highDanger-item-unit">`+common.transNullundefinedToline(data[i].organizationName)+`</span></div>
                          <div class="highDanger-item-time">已持续`+data[i].intervalTime+`</div>  
                        </li>
                        `);
                      }else{//已处理
                        $("#fireHazardHistoryList_list_"+self.getNewId).append(`
                        <li class="highDager_detail" data-id="`+data[i].id+`">
                          <img class="highDanger-item-overtime-img" style="left:8%" src="/ilink-app-h5-zd/static/img/rdspFile_1554726645262.png"/>
                          <div class="highDanger-item-border">
                            <div class="highDanger-item-deal-num">`+data[i].alertNum+`</div>
                            <div class="highDanger-item-name">火情数量</div>
                          </div>
                          <div class="highDanger-item-desc">`+data[i].selfDesc+`</div>
                          <div class="highDanger-item-unit-desc"><i class="iconfont icon-APPicon_dingwei" style="color:#2471CA;margin-left:-3px;"></i><span class="highDanger-item-unit">`+common.transNullundefinedToline(data[i].organizationName)+`</span></div>
                          <div class="highDanger-item-time">已持续`+data[i].intervalTime+`</div>  
                        </li>
                        `);
                      }
                      $(".highDager_detail").click(function(event) {
                          var id = jQuery(event.currentTarget).attr("data-id");
                          app.router.navigate("/fireHazardDetail/"+id+"/1/");
                      });
                      // $("#fireHazardHistoryList_list").append(`
                      //     <div class="fireHazardHistoryList-every-list" id="`+data[i].id+`">
                      //         <div class="fireHazardHistoryList-center">
                      //           <span>`+moment(data[i].startTime).format("MM-DD HH:mm")+`</span>
                      //         </div>
                      //         <div class="fireHazard-bottom">
                      //           <img id="fireHazard_detailPic" src="`+picNo(data[i].viewUrl)+`" />
                      //           <div class="flag">
                      //             <div class="flag-left">
                      //               <span>`+common.transNullundefinedToline(data[i].organizationName)+`</span>
                      //             </div>
                      //             <div class="flag-right">
                      //               <div>
                      //                   <span class="iconfont icon-huo"></span>火情数量
                      //                   <span>`+data[i].alertNum+`</span>
                      //               </div>
                      //               <div class="fireHazard-delay-time">持续`+data[i].intervalTime+`</div>
                      //             </div>
                      //           </div>
                      //           <div class="right-top-flag fireHazard_style_bg_`+data[i].handlerStatus+`" id="keyIssues_style" >`+data[i].handlerStatusName+`</div>
                      //         </div>
                      //         <div class="fireHazardHistoryList-line"></div>
                      //     </div>
                      // `);
                      // $(".fireHazardHistoryList-every-list").click(function(event) {
                      //     var id = $(event.currentTarget).attr("id");
                      //     app.router.navigate("/fireHazardDetail/"+id+"/1/");
                      // });
                    }
                  }else{
                    $("#fireHazardHistoryList_preloader_"+self.getNewId).hide();
                    if (self.pageIndex == 0) {
                        $("#fireHazardHistoryList_list_"+self.getNewId).append(`
                        <div class="no-data-img"><img src="`+listNoDataPic()+`"/></div>`);
                    }
                  }
                });
            },
            //加载更多
         /*   loadMore:function(){
               var self = this;
               if (self.isInfinite){
                  setTimeout(function () {
                self.pageIndex++;
                self.showfireHazardHistoryList();
              }, 1000);
               }
            },*/
             loadMore: function () {
              var self = this;
              var $ = self.$$;
              if (!self.isInfinite) return;
              self.isInfinite = false;
              setTimeout(function () {
                self.pageIndex++;
                self.showfireHazardHistoryList();
              }, 1000);
            },
            //时间筛选
            getTbTime:function(){
                var self = this;
                loadSelectedDate_Fn(3,function(data) {
                	  self.startTimeStr = data.startTime;
                    self.endTimeStr = data.endTime;
                    
                    jQuery("#fireHazardHistoryList_list_"+self.getNewId).empty();
                    jQuery("#fireHazardHistoryList_date_"+self.getNewId).html(self.startTimeStr.substring(5,10));
                    jQuery("#fireHazardHistoryList_date_"+self.getNewId).addClass("select-active")
                    self.clearContent();
                    self.showfireHazardHistoryList();
                }); 
            },
            clearContent:function() {
                if (this.startTimeStr!=''|| this.organizationIds!=userInfor.organizationIds){
                    $("#fire-search").addClass('search-select');
                } else {
                    $("#fire-search").removeClass('search-select');
                }
            },
        },
        on: {
          pageInit:function (e, page) {
            var self = this;
            var $ = self.$$;
            $("#fireHazardHistoryList_list_"+self.getNewId).empty();
            self.showfireHazardHistoryList();

            //选择单位

            jQuery("#fireHazardHistoryList_org_"+self.getNewId).click(function(e) {
                loadSelectUnitFunc(function(data){
                    //选中
                    if(self.selectOptionOrg != data.orgId){
                        self.selectOptionOrg = data.orgId;
                        self.organizationIds = data.orgId;
                        jQuery("#fireHazardHistoryList_org_"+self.getNewId).html(data.orgName);
                        jQuery("#fireHazardHistoryList_org_"+self.getNewId).addClass('select-active');
                    } else {
                        self.selectOptionOrg = "";
                        if (single_Orgid == "") {
                          self.organizationIds=userInfor.organizationIds;
                        } else {
                          self.organizationIds=single_Orgid;
                        }
                        jQuery("#fireHazardHistoryList_org_"+self.getNewId).html("选择单位");
                        jQuery("#fireHazardHistoryList_org_"+self.getNewId).removeClass('select-active');
                    }
                    jQuery("#fireHazardHistoryList_list_"+self.getNewId).empty();
                    self.clearContent();
                    self.showfireHazardHistoryList();
                },self.selectOptionOrg);
            });
          }
        }
      }
</script>